package com.example.day23.ex04;

import java.util.function.Supplier;

public class SupplierTest {
    public static void main(String[] args) {
        int[]arr={1,2,3,4,5,6,7,8,9,10};
        int maxValue=getMax(()->{
            int max=arr[0];
            for (int i = 1; i < arr.length; i++) {
                if (arr[i]>max){
                    max=arr[i];
                }
            }
            return max;
        });
        System.out.println("最大值为："+maxValue);
    }
    private static int getMax(Supplier<Integer> supplier){
        return supplier.get();
    }
}
